package com.nativetalk.controller.app.four.teacher.comment;

import com.nativetalk.base.RetInfo;
import com.nativetalk.bean.comment.TdNtCommentInsert;
import com.nativetalk.common.Constants;
import com.nativetalk.common.util.JsonUtil;
import com.nativetalk.service.four.comment.FourCommentService;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * Created by lizhun on 15/12/9.
 */
@Controller
public class FourTeacherCommentController {
    private static Logger logger = Logger.getLogger(FourTeacherCommentController.class);
    @Resource
    private FourCommentService fourCommentService;

    /**
     * @return RetInfo
     * @Purpose 回复评论
     * @version 4.0
     * @time 2016-10-27
     * @author lizhun
     */
    @RequestMapping(value = "/app/10/teatoken/comment/repaly", method = {RequestMethod.GET, RequestMethod.POST}, consumes = "application/json")
    @ResponseBody
    public RetInfo replay(@RequestBody TdNtCommentInsert tdNtCommentInsert) {
        try {
            //打印入参
            logger.info(Constants.prefix_in + JsonUtil.toJson(tdNtCommentInsert));

            RetInfo retInfo = fourCommentService.replay(tdNtCommentInsert);

            //打印出参
            logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        } catch (Exception e) {
            //记录错误日志
            RetInfo retInfo = RetInfo.getServerErrorInfo();
            logger.error(e.getMessage(), e);

            //打印出参
            logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        }
    }

}


